
import os

class Utilities:

	@staticmethod
	def get_files_of_directory(directory):
		files = []
		dirList=os.listdir(directory)
		for fname in dirList:
			files.append(fname)
		return files

	@staticmethod
	def get_classes(root_path):
		return Utilities.get_files_of_directory(root_path)

	@staticmethod
	def get_documents_path(root_path, class_name):
		docs = Utilities.get_files_of_directory(root_path+class_name+'/')
		for i in range(len(docs)):
			docs[i]= root_path+class_name+'/'+docs[i]
		return docs

	@staticmethod
	def read_document(path):
		file = open(path)
		text = file.read()
		file.close()
		#text = text.encode('utf-8')
		return text

	@staticmethod
	def write_document(path, text):
		output = file(path, 'w')
		output.write(text)
		output.close()

